import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "normalize.css";
import "@/assets/css/common.scss";
/* 消息提示 */
import Message from '@/components/utils/message/index'
Vue.prototype.$message = Message;
//确定框组件
import confirm from '@/components/utils/Confirm'
Vue.prototype.$confirm = confirm
Vue.config.productionTip = false;
/* 设置全局自定义指令进行图片懒加载 */
import errorImg from "@/assets/img/下载.png";
Vue.directive("lazy", {
  inserted(el, binding) {
    const observer = new IntersectionObserver(([{ isIntersecting }]) => {
      if (isIntersecting) {
        observer.unobserve(el);
        // console.log(binding)
        el.src = binding.value;
        //图片加载失败
        el.onerror = () => {
          el.src = errorImg;
        };
      }
    });
    observer.observe(el);
  },
});
new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
